﻿@model CustomerOrderListModel
@{
    Layout = "~/Views/Shared/_Root.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Account").Text);
}
@using Nop.Web.Framework;
@using Nop.Web.Models.Customer;
<div class="account-page">
    <div class="page-title">
        <h1>@T("Account.CustomerOrders")</h1>
    </div>
    <div class="clear">
    </div>
    <div class="body">
        <div class="customer-orders">
            @if (Model.RecurringOrders.Count > 0)
            {
                if (Model.CancelRecurringPaymentErrors.Count > 0)
                {
                <div class="message-error">
                        @for (int i = 0; i < Model.CancelRecurringPaymentErrors.Count; i++)
                        {
                            @Model.CancelRecurringPaymentErrors[i]
                            if (i != Model.CancelRecurringPaymentErrors.Count - 1)
                            {
                            <br />
                            }
                        }
                </div>
                <div class="clear">
                </div>
                }
                using (Html.BeginForm())
                {
                <div class="recurring-payments">
                    <div class="section-title">
                        @T("Account.CustomerOrders.RecurringOrders")
                    </div>
                    <div class="clear">
                    </div>
                    <div>
                        <ul data-role="listview" data-inset="true" data-filter="false">
                            @foreach (var item in Model.RecurringOrders)
                            {
                                <li>
                                    <div class="recurring-payments-box">
                                        <div>
                                            @T("Account.CustomerOrders.RecurringOrders.StartDate"): @item.StartDate
                                        </div>
                                        <div>
                                            @T("Account.CustomerOrders.RecurringOrders.CycleInfo"): @item.CycleInfo</div>
                                        <div>
                                            @T("Account.CustomerOrders.RecurringOrders.NextPayment"): @item.NextPayment</div>
                                        <div>
                                            @T("Account.CustomerOrders.RecurringOrders.TotalCycles"): @item.TotalCycles
                                        </div>
                                        <div>
                                            @T("Account.CustomerOrders.RecurringOrders.CyclesRemaining"): @item.CyclesRemaining
                                        </div>
                                        <div>
                                            @T("Account.CustomerOrders.RecurringOrders.InitialOrder"): <a class="link" href="@Url.RouteUrl("OrderDetails", new { orderId = @item.InitialOrderId })">@string.Format(@T("Account.CustomerOrders.RecurringOrders.ViewInitialOrder").Text, item.InitialOrderId)</a>
                                        </div>
                                        <div class="buttons">
                                            @if (item.CanCancel)
                                            {
                                                <input type="submit" name="cancelRecurringPayment@(item.Id)" value="@T("Account.CustomerOrders.RecurringOrders.Cancel")" id="cancelRecurringPayment@(item.Id)" />
                                            }
                                        </div>
                                    </div>
                                </li>
                            }
                        </ul>
                    </div>
                </div>
                }
                <div class="clear">
                </div>
            }
            <div class="order-list">
                @if (Model.Orders.Count > 0)
                {
                    <ul data-role="listview" data-inset="true" data-filter="false">
                        @foreach (var order in Model.Orders)
                        {
                            <li>
                                <div class="order-item">
                                    <div>
                                        <div>
                                            <b>@T("Account.CustomerOrders.OrderNumber"): @order.Id</b>
                                        </div>
                                        <div>
                                            @T("Account.CustomerOrders.OrderStatus"): @order.OrderStatus</div>
                                        <div>
                                            @T("Account.CustomerOrders.OrderDate"): @order.CreatedOn.ToString()</div>
                                        <div>
                                            @T("Account.CustomerOrders.OrderTotal"): @order.OrderTotal
                                        </div>
                                    </div>
                                    <div class="buttons">
                                        @if (order.IsReturnRequestAllowed)
                                        {
                                            <a href="@Url.RouteUrl("ReturnRequest", new { orderId = @order.Id })" data-role="button">@T("Account.CustomerOrders.ReturnItems")</a>
                                        }
                                        <a href="@Url.RouteUrl("OrderDetails", new { orderId = @order.Id })" data-role="button">@T("Account.CustomerOrders.OrderDetails")</a>
                                    </div>
                                </div>
                            </li>
                        }
                    </ul>
                }
                else
                {
                    @T("Account.CustomerOrders.NoOrders")
                }
            </div>
        </div>
    </div>
</div>
